package com.superwein.alibaba.dubbo.consumer.service;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class LimitExceptionHandleService {

    /**
     * 限流处理
     *
     * @param str
     */
    @SentinelResource(value = "doSomeThing1", blockHandler = "exceptionHandler")
    public String doSomeThing(String str) {
        log.info(str);
        return str;
    }

    // 限流与阻塞处理
    public String exceptionHandler(String str, BlockException ex) {
        log.error("blockHandler：" + str, ex);
        return "blockHandler：" + str;
    }

}
